package com.mages.aspect.controller;

import com.mages.aspect.REST.AspectRESTTemplate;
import com.mages.aspect.service.*;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class AspectController {

    @RequestMapping(value="/aspect",method = {RequestMethod.GET,RequestMethod.POST})
    public AspectRESTTemplate aspect_service(@RequestParam("data_url") String data_url,
                                           @RequestParam("output_url") String output_url,
                                           @RequestParam("request_uuid") String request_uuid,
                                           @RequestParam("client_ip") String client_ip,
                                           @RequestParam("client_name") String client_name,
                                           @RequestParam("req_timestamp") long req_timestamp){
        AspectService service = new AspectService(data_url, output_url, request_uuid, client_name, client_ip,req_timestamp);
        return service.RunAspect();
    }

    @RequestMapping(value="/aspect/logs",method = {RequestMethod.GET,RequestMethod.POST})
    public List<String> Logs_service(){
        LogsService logsService = new LogsService();
        return logsService.ReadLogs();
    }

    @RequestMapping(value="/aspect/concurrency",method = {RequestMethod.GET,RequestMethod.POST})
    public Integer Cocurrency_service(){
        ConcurrencyService concurrencyService = new ConcurrencyService();
        return concurrencyService.QueryConcurrency();
    }

    @GetMapping("/aspect/test")
    public String test(){
        return "ok";}
}
